/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Hogar;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Temper extends Form implements CommandListener, ItemStateListener{
private Command aceptar;
private Gauge nivel;
private Hogar midlet;
private int temperatura;
public Temper(Hogar m){
super("Seleccione temperatura");
midlet = m;
nivel = new Gauge("18 ºC",true,15,3);
temperatura = 18;
aceptar = new Command("Aceptar",Command.OK,1);
this.append(nivel);
this.addCommand(aceptar);
this.setCommandListener(this);
this.setItemStateListener(this);
}
public void itemStateChanged(Item item){
if (item == nivel){//Controlo el Gauge
temperatura = (nivel.getValue()+15);
nivel.setLabel(temperatura+" ºC");
}
}
public void commandAction(Command c, Displayable d){
if (c == aceptar){
midlet.edificio.setTempHab(temperatura);
midlet.setCalefaccion();
}
}
public int getTemperatura(){
return temperatura;
}
}
